package com.feihong.newzxclient.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.widget.ImageView;
import com.feihong.newzxclient.R;

/**
 * @author song
 */
public class WelcomeActivity extends BaseActivity {

	private ImageView welcome_page;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
		
		getWindow().setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON, WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
		setContentView(R.layout.welcome_layout);
		initView();
		createAnimation();
	}
	
	public void initView() {
		
		welcome_page = (ImageView) this.findViewById(R.id.welcome_page);
	}
	
	private void createAnimation() {
		// TODO Auto-generated method stub
		AlphaAnimation alpAni = new AlphaAnimation(0.0f, 1.0f);
		alpAni.setDuration(2000);
		welcome_page.startAnimation(alpAni);
		alpAni.setAnimationListener(new MyAnimationListener());
	}
	
	@Override
	protected void onStart() {
		super.onStart();
	}
	
	private class MyAnimationListener implements AnimationListener {

		@Override
		public void onAnimationEnd(Animation animation) {
			Intent intent = new Intent();
			intent.setClass(WelcomeActivity.this, LoginActivity.class);
			startActivity(intent);
			finish();
		}

		@Override
		public void onAnimationRepeat(Animation animation) {

		}

		@Override
		public void onAnimationStart(Animation animation) {

		}
	}

}